Skip to content

Support adaptive background thresholding for Xenium data via stain_bg_percentile argument#22

Open
katwre wants to merge 2 commits intochenhcs:mainfrom
katwre:SCS2Visium
Open

Support adaptive background thresholding for Xenium data via stain_bg_percentile argument#22
katwre wants to merge 2 commits intochenhcs:mainfrom
katwre:SCS2Visium

Conversation

@katwre
Copy link
Copy Markdown

@katwre katwre commented Apr 24, 2026

Hi hi,

I wanted to share my experience running SCS on 10x Xenium data - I'm trying to add it to the nf-core spatialxe pipeline ( nf-core/spatialxe#130 ). I found that the default background threshold (stain_bg_threshold=10) does not work well for Xenium data, since almost all pixels have values above 10. This results in no background being detected and the model failing to train properly. That's a pull request related to the issue I just opened #21 . Please find in the attachment my test code Test_SCS2Visium.ipynb using the breast cancer tumor Xenium data (https://www.10xgenomics.com/products/xenium-in-situ/preview-dataset-human-breast), and the screenshot of the results:

Results_SCS_Xenium

I hope it's fine that I prepared a pull request to adjust for that. Summary of changes:

- Added an argument to the preprocess funcion called stain_bg_percentile that allows users to specify a percentile-based adaptive background threshold for stain intensity.
- Added a note in the README and example scripts about using stain_bg_percentile for Visium/H&E data.
- Clarified that the default threshold is for low-range fluorescence images, and percentile-based thresholding is recommended for H&E.

Let me know if you'd like any further changes. Thanks for maintaining SCS!

Cheers,
Kasia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant